package com.ruoyi.module.MemberInvestment.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.module.MemberInvestment.domain.MemberInvestment;
import com.ruoyi.module.MemberInvestment.service.IMemberInvestmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 协会招商专栏Controller
 * 
 * @author yqq
 * @date 2024-07-17
 */
@RestController
@RequestMapping("/api/MemberInvestment")
public class MemberInvestmentController extends BaseController
{
    @Autowired
    private IMemberInvestmentService memberInvestmentService;

    /**
     * 查询协会招商专栏列表
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestment:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberInvestment memberInvestment)
    {
        startPage();
        List<MemberInvestment> list = memberInvestmentService.selectMemberInvestmentList(memberInvestment);
        return getDataTable(list);
    }

    /**
     * 导出协会招商专栏列表
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestment:export')")
    @Log(title = "协会招商专栏", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberInvestment memberInvestment)
    {
        List<MemberInvestment> list = memberInvestmentService.selectMemberInvestmentList(memberInvestment);
        ExcelUtil<MemberInvestment> util = new ExcelUtil<MemberInvestment>(MemberInvestment.class);
        util.exportExcel(response, list, "协会招商专栏数据");
    }

    /**
     * 获取协会招商专栏详细信息
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestment:query')")
    @GetMapping(value = "/{investmentId}")
    public AjaxResult getInfo(@PathVariable("investmentId") Long investmentId)
    {
        return success(memberInvestmentService.selectMemberInvestmentByInvestmentId(investmentId));
    }

    /**
     * 新增协会招商专栏
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestment:add')")
    @Log(title = "协会招商专栏", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody MemberInvestment memberInvestment)
    {
        return toAjax(memberInvestmentService.insertMemberInvestment(memberInvestment));
    }

    /**
     * 修改协会招商专栏
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestment:edit')")
    @Log(title = "协会招商专栏", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody MemberInvestment memberInvestment)
    {
        return toAjax(memberInvestmentService.updateMemberInvestment(memberInvestment));
    }

    /**
     * 删除协会招商专栏
     */
    @PreAuthorize("@ss.hasPermi('api:MemberInvestment:remove')")
    @Log(title = "协会招商专栏", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{investmentId}")
    public AjaxResult remove(@PathVariable Long investmentId)
    {
        return toAjax(memberInvestmentService.deleteMemberInvestmentByInvestmentId(investmentId));
    }
}
